// router.js
// 
// var express = require('express');
// var router = express.Router();
var home = require('../app/controller/home/index');
var users = require('../app/controller/home/user');
var mypost = require('../app/controller/home/post');

//后台逻辑层
var adminIndex = require('../app/controller/admin/index');
var Content = require('../app/controller/admin/content');//内容管理

module.exports = function(app) {

	// pre handle user
	app.use(function(req, res, next) {
	var _user = req.session.user;
	app.locals.user = _user
	next()
	})
	//首页
	app.get('/', home.index);

	//会员
	app.get('/user', users.index);
	app.get('/user/reg', users.reg);//弹出框会员注册
	app.get('/user/signup', users.signup);//页面会员注册
	app.post('/user/reged', users.reged);//会员注册提交数据
	app.get('/user/login',users.login);// 会员登录
	app.get('/user/signin',users.signin);// 会员登录
	app.post('/user/logined',users.logined);//会员登录写入数据
	app.get('/user/logout', users.logout);//退出
	//post发帖
	app.get('/post', mypost.index);


	//后台控制
	app.get('/admin/index', users.signinRequired, users.adminRequired, adminIndex.index);//后台管理首页

	//内容管理
	app.get('/admin/content/index', users.signinRequired, users.adminRequired, Content.index);//内容管理首页（内容列表页）
} 